package com.huang.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huang.entity.Category;
import com.huang.mapper.CategoryMapper;
import com.huang.model.response.CategoryOptionResp;
import com.huang.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分类服务类
 *
 * @author Ikaros
 * @since 2025/9/26 10:51 星期五
 */
@Service
public class CategoryService extends ServiceImpl<CategoryMapper, Category> {

    /**
     * 查询分类选项列表
     *
     * @return 分类选项列表
     */
    public List<CategoryOptionResp> listCategoryOption() {
        // 查询分类
        List<Category> categoryList = baseMapper.selectList(new LambdaQueryWrapper<Category>()
                .orderByDesc(Category::getId));
        return BeanCopyUtils.copyBeanList(categoryList, CategoryOptionResp.class);
    }
}
